package me.luger.project.fof.controller.api;

import me.luger.core.commom.util.LogUtil;
import me.luger.core.dao.nutz.entity.page.Pagination;
import me.luger.core.mvc.controller.BaseController;
import me.luger.core.mvc.entity.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.bind.annotation.ResponseBody;

import me.luger.project.fof.service.FundInfoService;
import me.luger.project.fof.entity.FundInfo;

import java.util.List;

/**
 * FundInfo controller
 */
@Controller
@RequestMapping("/api/fof/fundInfo")
public class FundInfoApiController extends BaseController {

    @Autowired
    private FundInfoService fundInfoService;


    @RequestMapping(value = "/getFundsInfo",name = "根据传过来的基金ID获取基金信息")
    @ResponseBody
    public Object getFundsInfo(String[] fundIds){
        List<FundInfo> fundInfoList = null;
        try{
            fundInfoList = fundInfoService.getFundsInfo(fundIds);
        }catch (Exception e){
            LogUtil.errorLog(e,"");
            return Result.error();
        }
        return Result.success().addDateItem("fundList",fundInfoList);
    }

    @RequestMapping(value = "/getFundsInfoByManager",name = "根据基金经理获取基金列表")
    @ResponseBody
    public Object getFundsInfoByManager(@RequestParam(required = false,defaultValue = "1") Integer pn,
                                        @RequestParam(required = false,defaultValue = "10") Integer rn,
                                        String manager){
        Pagination<FundInfo> fundPageList = null;
        try{
            fundPageList = fundInfoService.getFundsInfoByManager(manager,pn,rn);
        }catch (Exception e){
            LogUtil.errorLog(e,"");
            return Result.error();
        }
        return Result.success(fundPageList);
    }
    @RequestMapping(value = "/getFundsInfoByManagement",name = "根据基金经理人获取基金列表")
    @ResponseBody
    public Object getFundsInfoByManagement(@RequestParam(required = false,defaultValue = "1") Integer pn,
                                           @RequestParam(required = false,defaultValue = "10") Integer rn,
                                           String management){
        Pagination<FundInfo> fundPageList = null;
        try{
            fundPageList = fundInfoService.getFundsInfoByManagement(management,pn,rn);
        }catch (Exception e){
            LogUtil.errorLog(e,"");
            return Result.error();
        }
        return Result.success(fundPageList);
    }

    @RequestMapping(value = "",name = "接口描述")
    @ResponseBody
    public Object demo(){
        try{

        }catch (Exception e){
            LogUtil.errorLog(e,"");
            return Result.error();
        }
        return Result.success();
    }
}
